package com.xqls.controller;

import com.alibaba.fastjson.JSONObject;
import com.xqls.biz.OperationRecordBiz;
import com.xqls.util.CommonPage;
import com.xqls.util.CommonResult;
import com.xqls.util.DictionaryEnums;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

@Controller
@RequestMapping("/operationRecord")
public class OperationRecordController {
	@Autowired
	private OperationRecordBiz orBiz;

	@RequestMapping("/operationRecordList/{modularNo}")
	public ModelAndView list(@PathVariable("modularNo")  Integer no){
		ModelAndView view = new ModelAndView("operationRecord/operationRecordList");
		view.addObject("network", DictionaryEnums.NET_WORK.getCode().toString());
		view.addObject("powerSupply", DictionaryEnums.POWER_SUPPLY.getCode().toString());
		view.addObject("instrument", DictionaryEnums.INSTRUMENT_DOOR.getCode().toString());
		view.addObject("operation", DictionaryEnums.OPERATION.getCode().toString());
		view.addObject("sampling", DictionaryEnums.SAMPLING_INSTRUMENT.getCode().toString());
		view.addObject("level", DictionaryEnums.LEVEL.getCode().toString());
		
		view.addObject("valve", DictionaryEnums.VALVE_OPERATION.getCode().toString());
		view.addObject("emergency", DictionaryEnums.EMERGENCY_PUMP.getCode().toString());
		view.addObject("modularNo", no);
		view.addObject("isRecordList", true);
		return view;
	}
	@RequestMapping("/operationRecordData")
	@ResponseBody
	public CommonResult listData(@RequestBody CommonPage commonPage, HttpServletRequest request, HttpServletResponse response){
		CommonResult result = orBiz.getOperationRecordsByPage(commonPage,request,response);
		if (result.getIsSuccess()) {
			result.setData(commonPage);
		}
		return result;
	}
	
	@RequestMapping("/getExcelByMap/{params}")
	public void getExcelByMap(HttpServletRequest request,HttpServletResponse response,@PathVariable(value = "params") String params) {
		JSONObject jsonObject=JSONObject.parseObject(params);
		this.orBiz.getExcelByMap(request, response, jsonObject); 
	}
	
	//排放口操作记录
	@RequestMapping("/dischargeOperation/{deviceNo}")
	public ModelAndView radioDischarge(@PathVariable(value = "deviceNo") String deviceNo){
		ModelAndView view = new ModelAndView("operationRecord/operationRecordList");
		view.addObject("modularNo", 3);
		view.addObject("deviceNo", deviceNo);
		view.addObject("network", DictionaryEnums.NET_WORK.getCode().toString());
		view.addObject("powerSupply", DictionaryEnums.POWER_SUPPLY.getCode().toString());
		view.addObject("instrument", DictionaryEnums.INSTRUMENT_DOOR.getCode().toString());
		view.addObject("operation", DictionaryEnums.OPERATION.getCode().toString());
		view.addObject("sampling", DictionaryEnums.SAMPLING_INSTRUMENT.getCode().toString());
		view.addObject("level", DictionaryEnums.LEVEL.getCode().toString());
		
		view.addObject("valve", DictionaryEnums.VALVE_OPERATION.getCode().toString());
		view.addObject("emergency", DictionaryEnums.EMERGENCY_PUMP.getCode().toString());
		return view;
	}
	
	//企业雨水排放口操作记录
	@RequestMapping("/rainwaterOperation/{deviceNo}")
	public ModelAndView radioRainwater(@PathVariable(value = "deviceNo") String deviceNo){
		ModelAndView view = new ModelAndView("operationRecord/operationRecordList");
		view.addObject("modularNo", 4);
		view.addObject("deviceNo", deviceNo);
		view.addObject("network", DictionaryEnums.NET_WORK.getCode().toString());
		view.addObject("powerSupply", DictionaryEnums.POWER_SUPPLY.getCode().toString());
		view.addObject("instrument", DictionaryEnums.INSTRUMENT_DOOR.getCode().toString());
		view.addObject("operation", DictionaryEnums.OPERATION.getCode().toString());
		view.addObject("sampling", DictionaryEnums.SAMPLING_INSTRUMENT.getCode().toString());
		view.addObject("level", DictionaryEnums.LEVEL.getCode().toString());
		
		view.addObject("valve", DictionaryEnums.VALVE_OPERATION.getCode().toString());
		view.addObject("emergency", DictionaryEnums.EMERGENCY_PUMP.getCode().toString());
		return view;
	}
	
	//公共雨水排放口操作记录
	@RequestMapping("/stormwaterOperation/{deviceNo}")
	public ModelAndView radioStormwater(@PathVariable(value = "deviceNo") String deviceNo){
		ModelAndView view = new ModelAndView("operationRecord/operationRecordList");
		view.addObject("modularNo", 5);
		view.addObject("deviceNo", deviceNo);
		view.addObject("network", DictionaryEnums.NET_WORK.getCode().toString());
		view.addObject("powerSupply", DictionaryEnums.POWER_SUPPLY.getCode().toString());
		view.addObject("instrument", DictionaryEnums.INSTRUMENT_DOOR.getCode().toString());
		view.addObject("operation", DictionaryEnums.OPERATION.getCode().toString());
		view.addObject("sampling", DictionaryEnums.SAMPLING_INSTRUMENT.getCode().toString());
		view.addObject("level", DictionaryEnums.LEVEL.getCode().toString());
		
		view.addObject("valve", DictionaryEnums.VALVE_OPERATION.getCode().toString());
		view.addObject("emergency", DictionaryEnums.EMERGENCY_PUMP.getCode().toString());
		return view;
	}
	
	//废气排放口操作记录
	@RequestMapping("/sastegasOperation/{deviceNo}")
	public ModelAndView radioSastegas(@PathVariable(value = "deviceNo") String deviceNo){
		ModelAndView view = new ModelAndView("operationRecord/operationRecordList");
		view.addObject("modularNo", 6);
		view.addObject("deviceNo", deviceNo);
		view.addObject("network", DictionaryEnums.NET_WORK.getCode().toString());
		view.addObject("powerSupply", DictionaryEnums.POWER_SUPPLY.getCode().toString());
		view.addObject("instrument", DictionaryEnums.INSTRUMENT_DOOR.getCode().toString());
		view.addObject("operation", DictionaryEnums.OPERATION.getCode().toString());
		view.addObject("sampling", DictionaryEnums.SAMPLING_INSTRUMENT.getCode().toString());
		view.addObject("level", DictionaryEnums.LEVEL.getCode().toString());
		
		view.addObject("valve", DictionaryEnums.VALVE_OPERATION.getCode().toString());
		view.addObject("emergency", DictionaryEnums.EMERGENCY_PUMP.getCode().toString());
		return view;
	}
	
}
